package cn.tedu.spring.autowired.controller;

import cn.tedu.spring.autowired.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {
    // 注解：进行属性值注入
    // 方式1：属性注入
    @Autowired
    @Qualifier(value = "aaa")
    private UserService userService;

    // 方式2：set注入
    // @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    // 方式3：构造方法注入
    //@Autowired
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }

    public void con(){
        System.out.println("controller正在执行...");
        userService.serv();
    }
}
